// import { CHANGE_CART_LIST } from './../mutation.types'
import * as types from './../mutation.types'
export default {
  namespaced: true,
  state: {
    cartlist: []
  },
  getters: {
    totalNum (state) { // this.$store.getters['cart/totalNum']
      // if (state.login_state) {
      //   console.log(this.$store.state.login_state)

      // } else {
      //   return 0
      // }
      console.log(types)
      return state.cartlist.reduce((sum, item) => {
        return item.flag ? sum + item.num : sum + 0
      }, 0)
    }
  },
  mutations: {
    // [CHANGE_CART_LIST] (state, data) {
    //   state.cartlist = data.payload
    // }
    [types.CHANGE_CART_LIST] (state, data) {
      state.cartlist = data.payload
    }
  }
}
